package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.ThumbDao;
import com.delivery.www.po.Thumb;
import com.delivery.www.dao.DaoImpl.ThumbDaoImpl;
import com.delivery.www.service.ThumbService;

import java.util.List;

/**
 * @author 12970
 */
public class ThumbServiceImpl implements ThumbService {
    private final ThumbDao thumbDao = new ThumbDaoImpl();

    @Override
    public boolean doThumb(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return thumbDao.doThumb(userId, dishId) > 0;
        } else {
            return false;
        }
    }

    @Override
    public List<Thumb> getThumb(int userId) {
        if (userId > 0) {
            return thumbDao.getThumb(userId);
        } else {
            return null;
        }
    }

    @Override
    public boolean cancelThumb(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return thumbDao.cancelThumb(userId, dishId) > 0;
        } else {
            return false;
        }
    }

    @Override
    public Thumb getOneThumb(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return thumbDao.getOneThumb(userId, dishId);
        } else {
            return null;
        }
    }
}
